package xin.yangshuai.basic01.io;

import java.io.*;

/**
 * Hello
 *
 * @author shuai
 * @date 2022/4/7
 */
public class Hello {

    public static void main(String[] args) {
        File file = new File("E:\\down\\111.png");
        InputStream in = null;
        OutputStream out = null;

        try {
            byte[] b = new byte[1024];
            int read;
            in = new FileInputStream(file);
            out = new FileOutputStream("E:\\down\\123.png");
            while ((read = in.read(b)) != -1) {
                System.out.println(read);
                out.write(b, 0, read);
            }
        } catch (Exception e) {

        } finally {
            try {
                out.close();
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }


    public static void main1(String[] args) {
        File file = new File("E:\\down\\3931f44a49f6401f97ae42457ebf713d.png");
        InputStream in = null;
        OutputStream out = null;

        byte[] b = new byte[1024];

        try {
            int read;
            in = new FileInputStream(file);
            out = new FileOutputStream("E:\\down\\1234.png");
            while ((read = in.read()) != -1) {
                System.out.println(read);
                out.write(read);
            }
        } catch (Exception e) {

        } finally {
            try {
                out.close();
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }
}
